#ifndef __YLW_TIMERTHREAD_H__
#define __YLW_TIMERTHREAD_H__

#include  "Timer.hpp"
#include "Thread.hpp"

#include <functional>
#include <iostream>
using std::function;
using std::bind;
using std::endl;
using std::cout;

namespace ylw
{

class Timerthread
{
    using TimerCallback = function<void()>;

public:
Timerthread(TimerCallback && cb, int initialTime, int periodicTime)
: _timer(std::move(cb), initialTime, periodicTime)
, _thread(bind(&Timer::start,  &_timer))
{
}
void start(){
    _thread.start();
}
void stop(){
    _timer.stop();
    _thread.join();
}

private:
    Timer _timer;
    Thread _thread;
};

}// end of namespace ylw

#endif
